﻿using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.UI;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.BIZ;

namespace AnyOffice.general.rms.destroy
{
    public partial class read_file : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                int fileId = (Request.QueryString["file_id"] != null) ? int.Parse(Request.QueryString["file_id"].ToString()) : 0;
                DataTable table = new RmsFileDao().SelectByFileId(base.Conn, fileId);
                if (table.Rows.Count > 0)
                {
                    this.litFileCode.Text = table.Rows[0]["FileCode"].ToString();
                    if (table.Rows[0]["FileSubject"] != DBNull.Value)
                    {
                        this.litFileSubject.Text = table.Rows[0]["FileSubject"].ToString();
                    }
                    this.litFileTitle.Text = table.Rows[0]["FileTitle"].ToString();
                    if (table.Rows[0]["FileTitle0"] != DBNull.Value)
                    {
                        this.litFileTitle0.Text = table.Rows[0]["FileTitle0"].ToString();
                    }
                    if (table.Rows[0]["SendUnit"] != DBNull.Value)
                    {
                        this.litSendUnit.Text = table.Rows[0]["SendUnit"].ToString();
                    }
                    if (table.Rows[0]["SendDate"] != DBNull.Value)
                    {
                        this.litSendDate.Text = Convert.ToDateTime(table.Rows[0]["SendDate"].ToString()).ToString("yyyy-MM-dd");
                    }
                    if (table.Rows[0]["Secret"] != DBNull.Value)
                    {
                        this.litSecret.Text = new RmsCodeDao().GetCodeName(base.Conn, table.Rows[0]["Secret"].ToString(), RmsCodeDao.CodeType.Secret);
                    }
                    if (table.Rows[0]["Urgency"] != DBNull.Value)
                    {
                        this.litSecret.Text = new RmsCodeDao().GetCodeName(base.Conn, table.Rows[0]["Urgency"].ToString(), RmsCodeDao.CodeType.Urgency);
                    }
                    if (table.Rows[0]["FileKind"] != DBNull.Value)
                    {
                        this.litSecret.Text = new RmsCodeDao().GetCodeName(base.Conn, table.Rows[0]["FileKind"].ToString(), RmsCodeDao.CodeType.FileKind);
                    }
                    if (table.Rows[0]["FileType"] != DBNull.Value)
                    {
                        this.litSecret.Text = new RmsCodeDao().GetCodeName(base.Conn, table.Rows[0]["FileType"].ToString(), RmsCodeDao.CodeType.FileType);
                    }
                    if (table.Rows[0]["FilePage"] != DBNull.Value)
                    {
                        this.litFilePage.Text = table.Rows[0]["FilePage"].ToString();
                    }
                    if (table.Rows[0]["PrintPage"] != DBNull.Value)
                    {
                        this.litPrintPage.Text = table.Rows[0]["PrintPage"].ToString();
                    }
                    if (table.Rows[0]["RollId"] != DBNull.Value)
                    {
                        this.litRollName.Text = new RmsRollDao().GetRollName(base.Conn, Convert.ToInt32(table.Rows[0]["RollId"].ToString()));
                    }
                    if (table.Rows[0]["Remark"] != DBNull.Value)
                    {
                        this.litRemark.Text = table.Rows[0]["Remark"].ToString();
                    }
                    if (table.Rows[0]["AttachmentId"] == DBNull.Value)
                    {
                        this.litAttachment.Text = "无附件";
                    }
                    else
                    {
                        string attachmentId = table.Rows[0]["AttachmentId"].ToString();
                        if ((this.litAttachment.Text = AttachmentBiz.Display(base.Conn, attachmentId)) == string.Empty)
                        {
                            this.litAttachment.Text = "无附件";
                        }
                    }
                }
                else
                {
                    this.pnlMain.Visible = false;
                    this.litMessage.Text = base.ShowPromptClose("无此文件");
                }
            }

        }
    }
}
